package net.pws.oos.web.dto;

import javax.servlet.http.HttpServletRequest;

import net.pws.oos.biz.model.User;

public class UserTreeNodeDto extends AbstractTreeNode {

	@SuppressWarnings("unchecked")
	public static UserTreeNodeDto from(User user, HttpServletRequest request) {
		UserTreeNodeDto result = new UserTreeNodeDto();
		result.metadata.put("id", user.getId());
		result.metadata.put("name", user.getName());
		result.metadata.put("type", "user");
		result.setTitle(user.getName());
		result.data.put("icon", request.getContextPath() + "/images/user.png");
		return result;
	}

	public UserTreeNodeDto() {
		this.state = "leaf";
	}
}
